package com.example.mobile2021606128wje0330;

import android.accounts.Account;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private EditText edtTxtMainPsw;
    private EditText edtTxtMainAccount;
    private Button btnMainLogin;
    private Button btnMainRec;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }



    private void initView() {
        edtTxtMainPsw = (EditText) findViewById(R.id.edtTxt_main_psw);
        edtTxtMainAccount = (EditText) findViewById(R.id.edtTxt_main_account);
        btnMainLogin = (Button) findViewById(R.id.btn_main_login);
        btnMainRec = (Button) findViewById(R.id.btn_main_rec);
        btnMainLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //获取输入内容--判断--给出提示
                String str = edtTxtMainAccount.getText().toString();
                String str1 = edtTxtMainPsw.getText().toString();
                if (str.length()==0){
                    Log.i("登录","请输入账号");
                }else if (str1.length()==0){
                    Log.i("登录", "请输入密码");
                }else  {
                    //判断
                    if (str.equals("admin") & str1.equals("123456")) {
                        Log.i("登陆", "登陆成功");
                    } else {
                        Log.i("登陆", "登陆失败");
                    }
                    }
                }
            });
    }

}

